package com.doublefish.doublefishrobot.ui.video;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.doublefish.doublefishrobot.R;
import com.doublefish.doublefishrobot.base.BaseActivity;
import com.doublefish.doublefishrobot.utils.SharedPreferencesUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 作者:dugaofeng on 2024/10/31 09:33
 */
public class VideoDownloadSettingActivity extends BaseActivity {


    @BindView(R.id.tv_title)
    TextView titleTv;

    @BindView(R.id.iv_tick1)
    ImageView tickIv1;

    @BindView(R.id.iv_tick2)
    ImageView tickIv2;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_download_setting;
    }

    @Override
    protected void initView() {
        titleTv.setText(getString(R.string.video_download_setting));
    }

    @Override
    protected void initData() {
        //0.仅WiFi  1.WiFi和移动网络
        int downloadType = SharedPreferencesUtils.getInstant().getVideoDownloadType();
        setDownloadType(downloadType);
    }

    @Override
    protected void initListener() {

    }

    private void setDownloadType(int downloadType) {
        switch (downloadType) {
            case 0: {
                tickIv1.setVisibility(View.VISIBLE);
                tickIv2.setVisibility(View.INVISIBLE);
            }
            break;

            case 1: {
                tickIv1.setVisibility(View.INVISIBLE);
                tickIv2.setVisibility(View.VISIBLE);
            }
            break;
        }
    }

    private void saveDownloadType(int downloadType) {
        SharedPreferencesUtils.getInstant().setVideoDownloadType(downloadType);
    }

    @OnClick({R.id.ll_type_1, R.id.ll_type_2})
    public void onCLickView(View view) {
        switch (view.getId()) {
            case R.id.ll_type_1: {
                setDownloadType(0);
                saveDownloadType(0);
            }
            break;

            case R.id.ll_type_2: {
                setDownloadType(1);
                saveDownloadType(1);
            }
            break;
        }
    }

    @OnClick(R.id.ll_back)
    public void onBackBtnClick() {
        finish();
    }
}
